<?php

namespace app\command;
use think\App;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use app\order\logic\ReamazeLogic;
use app\order\logic\CheckbillLogic;
use app\api\logic\TestLogic;
use app\order\logic\OrderLogic;
use think\facade\Cache;
use app\api\logic\ApiStockUpLogic;
class ReamazeConsummer extends Command
{

        protected function configure()
        {
                $this->setName('ReamazeConsummer')
                ->setDescription('ReamazeConsummer');
        }

        protected function execute(Input $input, Output $output)
        {

                //每日洗数据--每日可用库存--新规则
                (new ApiStockUpLogic())->inventory_quantity_new();

                (new OrderLogic())->refundListAddfield();

                (new OrderLogic())->refundListAddfieldinfo();

                $ExpirationDate = Cache::store('redis')->get('ReamazeConsummer');
                if (empty($ExpirationDate)) {  
                        Cache::store('redis')->set('ReamazeConsummer', 1, 3600 * 24);
                }else{
                        echo '时间没到先不更新';die;
                }
                
// ------------------------------------------争议成本--先要获取交易记录 再匹配争议-匹配到了最后打标签
                // TODO : 更新工单邮箱
                (new OrderLogic())->UpdateWorkOrderEmail();
                //临时打元子段--dispute标签
                (new OrderLogic())->DisputeSubSegment();
// ------------------------------------------争议结束  

                //客服重新分配员工
                (new OrderLogic())->ReassignsEm();
                //回收分配
                (new OrderLogic())->RecyclingAndDistribution();
                //给visa打标签------VDMP----改成Master
                (new OrderLogic())->LabelVisa();
                 //给visa打标签------Paypal
                (new OrderLogic())->LabelPaypal();
                //海外仓打标签hwc-----------hwc
                (new OrderLogic())->WarehouseLabelHwc();
                 //拉取afterpay支付记录
                (new OrderLogic())->AfterpayPaymentsHistory();
                //临时打元子段--afterpay元子段
                (new OrderLogic())->TemporaryYuanSubSegment();
                //新增联系人
                (new OrderLogic())->contacts_update();
                //邮件改状态--工单合并
                (new OrderLogic())->conversations_update();
                //临时打元子段--dispute元字段
                (new OrderLogic())->DisputeSubSegment();
                //客服拉取会话列表
                (new OrderLogic())->Apireamazelabel();
                // 快速更新当月交易信息--shopify支付记录

                $ExpirationDate = Cache::store('redis')->get('ReamazeConsummerTransaction');
                if (empty($ExpirationDate)) {  
                        Cache::store('redis')->set('ReamazeConsummerTransaction', 1, 3600 * 24 * 5);
                }else{
                        echo '时间没到先不更新';die;
                }

                (new OrderLogic())->QueryOrderTransactionApi();
        }
}